package com.heima.admin.controller.v1;

import com.heima.model.admin.dtos.AdUserDto;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.admin.service.AdUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/login")
@Api(value = "管理平台登录Api" ,tags = "管理平台登录Api")
public class LoginController {

    @Autowired
    AdUserService userService;


    @PostMapping("/in")
    @ApiOperation("登录")
    public ResponseResult login(@RequestBody AdUserDto dto){
        return userService.loginIn(dto);
    }

    @PostMapping("/register")
    @ApiOperation("注册")
    public ResponseResult register(@RequestBody AdUser user){

        return userService.addAdUser(user);
    }
}
